Ext.define('byb.view.AccordionView', {
    extend: 'Ext.panel.Panel',
    alias: "widget.AccordionView",
    requires: ['Ext.layout.container.Accordion'],
    xtype: 'layout-accordion',
    cls: "AccordionView",
    layout: {
        type: 'accordion'
        // multi: true
    },
    width: '100%',
    initButton:null,
    initComponent: function() {
        this.callParent();
    },
    
    createItem: function(title, icon, array) {
        var me=this;
        var accordion = Ext.create('Ext.panel.Panel', {
            //title: "<span style='vertical-align:middle;height:38px;line-height:38px;display:inline-block'><img src="+icon+" style='margin-right:10px'/>"+title+"</span>"
            title:"<span style='background:url("+icon+") no-repeat 0 center;height:100%;line-height:100%;width:150px;display:inline-block;'><span style='margin-left:40px;font-size: 14px;font-weight:bold;color:#ccc'>"+title+"</span></span>"
        });
        Ext.Array.each(array, function(obj) {
            var button={
                xtype: 'button',
                width: 235,
                border: false,
                cls: 'bybbutton',
                ui:'byb',
                //text: obj.name,
                html: "<span style='text-align:left;display:block;margin-top:-1px;height:18px;line-height:18px;padding-left:50px;font-size:14px;color:#ccc'>"+obj.name+"</span>",
                listeners: {
                    click: function(ctx, e, eOpts){
                    	me.initButton =  {"button":ctx,"object":obj,"title":title};
                        this.fireEvent(byb.Constant.LeftMenuSelectedButton, {"button":ctx,"object":obj,"title":title});
                    },
                    afterrender:function(ctx, e,eOpts){
                        if(me.initButton==null){
                            this.fireEvent(byb.Constant.LeftMenuSelectedButton, {"button":ctx,"object":obj,"title":title});
                            me.initButton= {"button":ctx,"object":obj,"title":title};
                        }
                    }
                }
            };
            accordion.add(button);
        });
        return accordion;
    }
})